home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / MIXTREE.PAK / ITEMINFO.C < prev    next >
C/C++ Source or Header  |  1997-05-06  |  19KB  |  638 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993 - 1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE:   iteminfo.c
  9. //
  10. //  PURPOSE:  Obtain and display information associated with TreeView items.  
  11. //
  12. //  FUNCTIONS:
  13. //    GetItemInfo      - Query on information about the mixer line or control 
  14. //                       associated with a TreeView item.
  15. //    DisplayItemInfo  - Display the information for a mixer line or control 
  16. //                       associated with a TreeView item.
  17. //    GetComponentTypeString - Retrieve the description of a mixer line's
  18. //                       component type.
  19. //    GetControlTypeString   - Retrieve the description of a mixer control's
  20. //                       control type.
  21. //
  22. //  COMMENTS:
  23. //
  24.  
  25. #include <windows.h>                // required for all Windows applications.
  26. #include <windowsx.h>
  27. #include <memory.h>
  28.  
  29. #include "globals.h"                // prototypes specific to this application.
  30. #include "resource.h"
  31. #include "iteminfo.h"
  32.  
  33.  
  34. //
  35. //  FUNCTION: GetItemInfo(HWND, long)
  36. //
  37. //  PURPOSE: Get the information for the mixer line or control associated
  38. //           with a TreeView item.
  39. //
  40. //  PARAMETERS:
  41. //    hwnd     - application window handle.
  42. //    lItem    - index into array of MIXITEMINFO structures identifying
  43. //               TreeView item associated with a mixer line or control.
  44. //
  45. //  RETURN VALUE:
  46. //    TRUE     - Success.
  47. //    FALSE    - Failure.
  48. //
  49. //  COMMENTS:
  50. //    
  51. //
  52.  
  53. BOOL GetItemInfo(
  54.     HWND hwnd,
  55.     long lItem)
  56. {
  57.     MMRESULT result;
  58.  
  59.     if (lItem == MIXITEM_NOSELECTION)
  60.         return FALSE;
  61.  
  62.     switch (amixii[lItem].dwItemType)
  63.     {
  64.         case MIXITEM_UNDEFINED:
  65.             MessageBox(hwnd, "Item type undefined", 
  66.                        "MixTree Error", MB_ICONHAND);
  67.             return FALSE;
  68.  
  69.         case MIXITEM_MIXERLINE:
  70.             _fmemset((LPBYTE)&mlCurrent, 0, sizeof(MIXERLINE));
  71.             mlCurrent.cbStruct = sizeof(MIXERLINE);
  72.             mlCurrent.dwLineID = amixii[lItem].dwLineID;
  73.  
  74.             // get the line information
  75.             result = GetLineInfo(hwnd, &mlCurrent, MIXER_GETLINEINFOF_LINEID);
  76.             if (result)
  77.                 return FALSE;
  78.  
  79.             break;
  80.  
  81.         case MIXITEM_MIXERCONTROL:
  82.         {
  83.             MIXERLINECONTROLS mlcs;
  84.  
  85.             _fmemset((LPBYTE)&mlcs, 0, sizeof(MIXERLINECONTROLS));
  86.             mlcs.cbStruct = sizeof(MIXERLINECONTROLS);
  87.  
  88.             // MIXERLINECONTROLS uses anonymous unions, which are not supported in
  89.             // C.  The code below is conditionalized to show you how the usage
  90.             // differs between C and C++.
  91.             #if defined (__cplusplus)
  92.             mlcs.dwControlID = amixii[lItem].dwControlID;
  93.             #else
  94.             mlcs.u.dwControlID = amixii[lItem].dwControlID;
  95.             #endif
  96.  
  97.             mlcs.cControls = 1;
  98.             mlcs.cbmxctrl = sizeof(MIXERCONTROL);  
  99.             _fmemset((LPBYTE)&mcCurrent, 0, sizeof(MIXERCONTROL));                      
  100.             mlcs.pamxctrl = (LPMIXERCONTROL)&mcCurrent;    
  101.       
  102.             result = GetLineControls(hwnd, 
  103.                          &mlcs, 
  104.                          MIXER_GETLINECONTROLSF_ONEBYID);
  105.             if (result)
  106.                 return (FALSE);
  107.                                         
  108.             break;
  109.         }
  110.  
  111.         default:
  112.             MessageBox(hwnd, "Bad item type", "MixTree Error", MB_ICONHAND);
  113.             return FALSE;
  114.     }
  115.  
  116.     return TRUE;
  117. }
  118.  
  119.  
  120. //
  121. //  FUNCTION: DisplayItemInfo(HWND, HDC)
  122. //
  123. //  PURPOSE: Display a TreeView item's mixer line or control information.
  124. //
  125. //  PARAMETERS:
  126. //    hwnd     - application window handle.
  127. //    hdc      - handle to display context.
  128. //
  129. //  RETURN VALUE:
  130. //    nothing.    
  131. //
  132. //  COMMENTS:
  133. //    
  134. //
  135.  
  136. void DisplayItemInfo(
  137.     HWND hwnd,
  138.     HDC hdc)
  139. {
  140.     RECT rc;
  141.     POINT pt;
  142.     TEXTMETRIC tm;
  143.     SIZE size;
  144.     int dx, dy;
  145.     char achBuf[80];
  146.     char achTypeBuf[80];
  147.  
  148.     HFONT hfOldFont;
  149.  
  150.     if (!hwnd || !hdc)
  151.     {
  152.         OutputDebugString("Bad hWnd or hDC in DisplayItemInfo\r\n");
  153.         return;
  154.     }
  155.  
  156.     hfOldFont = SelectObject(hdc, hfTVFont);
  157.  
  158.     GetClientRect(hwnd, &rc);
  159.  
  160.     pt.x = (rc.right / 3);
  161.     PatBlt(hdc, 
  162.            pt.x + 1, 0,
  163.            rc.right - pt.x - 1, rc.bottom,
  164.            WHITENESS);
  165.    
  166.     if (lCurrentItem == MIXITEM_NOSELECTION)
  167.         return;
  168.  
  169.     pt.x += 10;
  170.     pt.y = 0;
  171.     GetTextMetrics(hdc, &tm);
  172.     dy = tm.tmHeight + tm.tmExternalLeading;
  173.  
  174.     if (lCurrentItem == MIXITEM_NOSELECTION || 
  175.             amixii[lCurrentItem].dwItemType == MIXITEM_UNDEFINED)
  176.         wsprintf((LPSTR)achBuf, 
  177.             (LPSTR)"Select a mixer line or control with the mouse.");
  178.     else
  179.         wsprintf((LPSTR)achBuf, (LPSTR)"Current Selection:");
  180.     TextOut(hdc, pt.x, pt.y, achBuf, strlen(achBuf));
  181.  
  182.     switch (amixii[lCurrentItem].dwItemType)
  183.     {
  184.         case MIXITEM_MIXERLINE:              
  185.             GetTextExtentPoint(hdc, "Target.vDriverVersion ", 22, &size);
  186.             dx = size.cx;
  187.            
  188.             wsprintf((LPSTR)achBuf, 
  189.                      (LPSTR)"Item type");
  190.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  191.             wsprintf((LPSTR)achBuf, 
  192.                      (LPSTR)"= MIXERLINE");
  193.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  194.  
  195.             wsprintf((LPSTR)achBuf, 
  196.                      (LPSTR)"cbStruct");                    
  197.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  198.             wsprintf((LPSTR)achBuf, 
  199.                      (LPSTR)"= %lu", 
  200.                      mlCurrent.cbStruct);
  201.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  202.  
  203.             wsprintf((LPSTR)achBuf,     
  204.                      (LPSTR)"dwDestination");
  205.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  206.             wsprintf((LPSTR)achBuf,     
  207.                      (LPSTR)"= %lu", 
  208.                      mlCurrent.dwDestination);
  209.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  210.  
  211.             wsprintf((LPSTR)achBuf, 
  212.                      (LPSTR)"dwSource");
  213.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  214.             wsprintf((LPSTR)achBuf, 
  215.                      (LPSTR)"= %lu", 
  216.                      mlCurrent.dwSource);
  217.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  218.  
  219.             wsprintf((LPSTR)achBuf, 
  220.                      (LPSTR)"dwLineID");
  221.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  222.             wsprintf((LPSTR)achBuf,                     
  223.                      (LPSTR)"= %lXH", 
  224.                      mlCurrent.dwLineID);
  225.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  226.  
  227.             wsprintf((LPSTR)achBuf, 
  228.                      (LPSTR)"fdwLine");
  229.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  230.             wsprintf((LPSTR)achBuf, 
  231.                      (LPSTR)"= %lXH", 
  232.                      mlCurrent.fdwLine);
  233.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  234.  
  235.             wsprintf((LPSTR)achBuf, 
  236.                      (LPSTR)"dwUser");
  237.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  238.             wsprintf((LPSTR)achBuf, 
  239.                      (LPSTR)"= %lu", 
  240.                      mlCurrent.dwUser);             
  241.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  242.  
  243.             GetComponentTypeString(mlCurrent.dwComponentType, 
  244.                                    (LPSTR)achTypeBuf,
  245.                                    sizeof(achTypeBuf));
  246.             wsprintf((LPSTR)achBuf, 
  247.                      (LPSTR)"dwComponentType");
  248.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  249.             wsprintf((LPSTR)achBuf, 
  250.                      (LPSTR)"= %s", 
  251.                      (LPSTR)achTypeBuf);
  252.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  253.  
  254.             wsprintf((LPSTR)achBuf, 
  255.                      (LPSTR)"cChannels");
  256.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  257.             wsprintf((LPSTR)achBuf, 
  258.                      (LPSTR)"= %lu", 
  259.                      mlCurrent.cChannels);
  260.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  261.  
  262.             wsprintf((LPSTR)achBuf, 
  263.                      (LPSTR)"cConnections");
  264.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  265.             wsprintf((LPSTR)achBuf, 
  266.                      (LPSTR)"= %lu", 
  267.                      mlCurrent.cConnections);
  268.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  269.  
  270.             wsprintf((LPSTR)achBuf, 
  271.                      (LPSTR)"cControls");
  272.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));  
  273.             wsprintf((LPSTR)achBuf, 
  274.                      (LPSTR)"= %lu", 
  275.                      mlCurrent.cControls);
  276.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  277.  
  278.             wsprintf((LPSTR)achBuf, 
  279.                      (LPSTR)"szShortName");
  280.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  281.             wsprintf((LPSTR)achBuf, 
  282.                      (LPSTR)"= %s", 
  283.                      (LPSTR)mlCurrent.szShortName);
  284.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  285.  
  286.             wsprintf((LPSTR)achBuf, 
  287.                      (LPSTR)"szName");
  288.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  289.             wsprintf((LPSTR)achBuf, 
  290.                      (LPSTR)"= %s", 
  291.                      (LPSTR)mlCurrent.szName);
  292.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  293.  
  294.             wsprintf((LPSTR)achBuf, 
  295.                      (LPSTR)"Target.dwType");
  296.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  297.             wsprintf((LPSTR)achBuf, 
  298.                      (LPSTR)"= %lu", 
  299.                      mlCurrent.Target.dwType);  
  300.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  301.  
  302.             if (mlCurrent.Target.dwType == MIXERLINE_TARGETTYPE_UNDEFINED)
  303.                 // ignore the remainder of the Target structure
  304.                 break;
  305.  
  306.             wsprintf((LPSTR)achBuf, 
  307.                      (LPSTR)"Target.dwDeviceID");
  308.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  309.             wsprintf((LPSTR)achBuf, 
  310.                      (LPSTR)"= %lu", 
  311.                      mlCurrent.Target.dwType);
  312.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  313.  
  314.             wsprintf((LPSTR)achBuf, 
  315.                      (LPSTR)"Target.wMid");
  316.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  317.             wsprintf((LPSTR)achBuf, 
  318.                      (LPSTR)"= %u", 
  319.                      mlCurrent.Target.wMid);
  320.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  321.  
  322.             wsprintf((LPSTR)achBuf, 
  323.                      (LPSTR)"Target.wPid");
  324.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  325.             wsprintf((LPSTR)achBuf, 
  326.                      (LPSTR)"= %u", 
  327.                      mlCurrent.Target.wPid);
  328.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  329.  
  330.             wsprintf((LPSTR)achBuf, 
  331.                      (LPSTR)"Target.vDriverVersion = %u.%u", 
  332.                      HIBYTE(mlCurrent.Target.vDriverVersion),
  333.                      LOBYTE(mlCurrent.Target.vDriverVersion));
  334.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  335.            
  336.             wsprintf((LPSTR)achBuf, 
  337.                      (LPSTR)"szPname");
  338.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf)); 
  339.             wsprintf((LPSTR)achBuf, 
  340.                      (LPSTR)"= %s", 
  341.                      (LPSTR)mlCurrent.Target.szPname);
  342.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  343.             break;
  344.  
  345.         case MIXITEM_MIXERCONTROL:
  346.             GetTextExtentPoint(hdc, "Bounds.dwMaximum ", 17, &size);
  347.             dx = size.cx;
  348.  
  349.             wsprintf((LPSTR)achBuf, 
  350.                 (LPSTR)"Item type");
  351.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));  
  352.             wsprintf((LPSTR)achBuf, 
  353.                      (LPSTR)"= MIXERCONTROL");
  354.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));      
  355.  
  356.             wsprintf((LPSTR)achBuf, 
  357.                      (LPSTR)"cbStruct");
  358.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  359.             wsprintf((LPSTR)achBuf, 
  360.                      (LPSTR)"= %lu", 
  361.                      mcCurrent.cbStruct);
  362.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  363.  
  364.             wsprintf((LPSTR)achBuf, 
  365.                      (LPSTR)"dwControlID");
  366.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  367.             wsprintf((LPSTR)achBuf, 
  368.                      (LPSTR)"= %lu", 
  369.                      mcCurrent.dwControlID);
  370.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  371.  
  372.             GetControlTypeString(mcCurrent.dwControlType, 
  373.                                  (LPSTR)achTypeBuf,
  374.                                  sizeof(achTypeBuf));
  375.             wsprintf((LPSTR)achBuf, 
  376.                      (LPSTR)"dwControlType");                                    
  377.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  378.             wsprintf((LPSTR)achBuf, 
  379.                      (LPSTR)"= %s", 
  380.                      (LPSTR)achTypeBuf);
  381.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  382.  
  383.             wsprintf((LPSTR)achBuf, 
  384.                      (LPSTR)"fdwControl");
  385.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  386.             wsprintf((LPSTR)achBuf, 
  387.                      (LPSTR)"= %lu", 
  388.                      mcCurrent.fdwControl);
  389.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  390.  
  391.             wsprintf((LPSTR)achBuf, 
  392.                      (LPSTR)"cMultipleItems");
  393.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  394.             wsprintf((LPSTR)achBuf, 
  395.                      (LPSTR)"= %lu", 
  396.                      mcCurrent.cMultipleItems);
  397.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  398.  
  399.             wsprintf((LPSTR)achBuf, 
  400.                      (LPSTR)"szShortName");
  401.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  402.             wsprintf((LPSTR)achBuf, 
  403.                      (LPSTR)"= %s", 
  404.                      (LPSTR)mcCurrent.szShortName);
  405.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  406.  
  407.             wsprintf((LPSTR)achBuf, 
  408.                      (LPSTR)"szName");
  409.             TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));     
  410.             wsprintf((LPSTR)achBuf, 
  411.                      (LPSTR)"= %s", 
  412.                      (LPSTR)mcCurrent.szName);
  413.             TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  414.  
  415.             switch (mcCurrent.dwControlType)
  416.             {                                 
  417.                 // controls with unsigned bounds 
  418.  
  419.                 case MIXERCONTROL_CONTROLTYPE_CUSTOM :
  420.                     // custom control could use either signed or unsigned
  421.                     // bounds -- arbitrarily we display it as unsigned
  422.                 case MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER :
  423.                 case MIXERCONTROL_CONTROLTYPE_UNSIGNED :
  424.                 case MIXERCONTROL_CONTROLTYPE_FADER :
  425.                 case MIXERCONTROL_CONTROLTYPE_VOLUME :
  426.                 case MIXERCONTROL_CONTROLTYPE_BASS :
  427.                 case MIXERCONTROL_CONTROLTYPE_TREBLE :
  428.                 case MIXERCONTROL_CONTROLTYPE_EQUALIZER :
  429.                 case MIXERCONTROL_CONTROLTYPE_MICROTIME :
  430.                 case MIXERCONTROL_CONTROLTYPE_MILLITIME :
  431.                     
  432.                     // display unsigned Bounds information                    
  433.                     wsprintf((LPSTR)achBuf, 
  434.                              (LPSTR)"Bounds.dwMinimum");
  435.                     TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));     
  436.  
  437.                     // MIXERCONTROL uses anonymous unions, which are not supported in
  438.                     // C.  The code below is conditionalized to show you how the
  439.                     // usage differs between C and C++.
  440.                     #if defined (__cplusplus)
  441.                     wsprintf((LPSTR)achBuf,
  442.                              (LPSTR)"= %lu",
  443.                              mcCurrent.Bounds.dwMinimum);
  444.                     #else
  445.                     wsprintf((LPSTR)achBuf,
  446.                              (LPSTR)"= %lu",
  447.                              mcCurrent.Bounds.s1.dwMinimum);
  448.                     #endif
  449.  
  450.                     TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  451.  
  452.                     wsprintf((LPSTR)achBuf,
  453.                              (LPSTR)"Bounds.dwMaximum");
  454.                     TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  455.  
  456.                     // MIXERCONTROL uses anonymous unions, which are not supported in
  457.                     // C.  The code below is conditionalized to show you how the
  458.                     // usage differs between C and C++.
  459.                     #if defined (__cplusplus)
  460.                     wsprintf((LPSTR)achBuf,
  461.                              (LPSTR)"= %lu",
  462.                              mcCurrent.Bounds.dwMaximum);
  463.                     #else
  464.                     wsprintf((LPSTR)achBuf,
  465.                              (LPSTR)"= %lu",
  466.                              mcCurrent.Bounds.s1.dwMaximum);
  467.                     #endif
  468.  
  469.                     TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  470.                     break;
  471.  
  472.                 // controls with signed bounds
  473.  
  474.                 case MIXERCONTROL_CONTROLTYPE_PEAKMETER :                
  475.                 case MIXERCONTROL_CONTROLTYPE_SIGNEDMETER :
  476.                 case MIXERCONTROL_CONTROLTYPE_SIGNED :
  477.                 case MIXERCONTROL_CONTROLTYPE_SLIDER :
  478.                 case MIXERCONTROL_CONTROLTYPE_PAN :
  479.                 case MIXERCONTROL_CONTROLTYPE_QSOUNDPAN :
  480.  
  481.                     // display signed Bounds information
  482.                     wsprintf((LPSTR)achBuf, 
  483.                              (LPSTR)"Bounds.lMinimum");
  484.                     TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));     
  485.  
  486.                     // MIXERCONTROL uses anonymous unions, which are not supported in
  487.                     // C.  The code below is conditionalized to show you how the
  488.                     // usage differs between C and C++.
  489.                     #if defined (__cplusplus)
  490.                     wsprintf((LPSTR)achBuf,
  491.                              (LPSTR)"= %li",
  492.                              mcCurrent.Bounds.lMinimum);
  493.                     #else
  494.                     wsprintf((LPSTR)achBuf,
  495.                              (LPSTR)"= %li",
  496.                              mcCurrent.Bounds.s.lMinimum);
  497.                     #endif
  498.  
  499.                     TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  500.  
  501.                     wsprintf((LPSTR)achBuf,
  502.                              (LPSTR)"Bounds.lMaximum");
  503.                     TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));
  504.  
  505.                     // MIXERCONTROL uses anonymous unions, which are not supported in
  506.                     // C.  The code below is conditionalized to show you how the
  507.                     // usage differs between C and C++.
  508.                     #if defined (__cplusplus)
  509.                     wsprintf((LPSTR)achBuf,
  510.                              (LPSTR)"= %li",
  511.                              mcCurrent.Bounds.lMaximum);
  512.                     #else
  513.                     wsprintf((LPSTR)achBuf,
  514.                              (LPSTR)"= %li",
  515.                              mcCurrent.Bounds.s.lMaximum);
  516.                     #endif
  517.  
  518.                     TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  519.  
  520.                     break;
  521.  
  522.                 // these controls do not use Bounds
  523.                 case MIXERCONTROL_CONTROLTYPE_BOOLEAN :
  524.                 case MIXERCONTROL_CONTROLTYPE_ONOFF :
  525.                 case MIXERCONTROL_CONTROLTYPE_MUTE :
  526.                 case MIXERCONTROL_CONTROLTYPE_MONO :
  527.                 case MIXERCONTROL_CONTROLTYPE_LOUDNESS :
  528.                 case MIXERCONTROL_CONTROLTYPE_STEREOENH :
  529.                 case MIXERCONTROL_CONTROLTYPE_SINGLESELECT :
  530.                 case MIXERCONTROL_CONTROLTYPE_MUX :
  531.                 case MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT :
  532.                 case MIXERCONTROL_CONTROLTYPE_MIXER :
  533.                 default:                                    
  534.                     break;
  535.             }
  536.  
  537.             if (mcCurrent.dwControlType == MIXERCONTROL_CONTROLTYPE_CUSTOM)
  538.             {              
  539.                 wsprintf((LPSTR)achBuf, 
  540.                          (LPSTR)"Metrics.cbCustomData");
  541.                 TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));     
  542.                 wsprintf((LPSTR)achBuf, 
  543.                          (LPSTR)"= %lu", 
  544.                          mcCurrent.Metrics.cbCustomData);
  545.                 TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  546.             }
  547.             else
  548.             {              
  549.                 wsprintf((LPSTR)achBuf, 
  550.                          (LPSTR)"Metrics.cSteps");
  551.                 TextOut(hdc, pt.x, pt.y += dy, achBuf, strlen(achBuf));     
  552.                 wsprintf((LPSTR)achBuf, 
  553.                          (LPSTR)"= %lu", 
  554.                          mcCurrent.Metrics.cSteps);
  555.                 TextOut(hdc, pt.x + dx, pt.y,  achBuf, strlen(achBuf));
  556.             }
  557.  
  558.             break;
  559.  
  560.         case MIXITEM_UNDEFINED:
  561.         default:
  562.             // nothing to display        
  563.             break;
  564.     }
  565.  
  566.     SelectObject(hdc, hfOldFont);
  567. }
  568.  
  569.  
  570. //
  571. //  FUNCTION: GetComponentTypeString(DWORD, LPSTR, int)
  572. //
  573. //  PURPOSE: Get the string describing the given type of mixer component.
  574. //
  575. //  PARAMETERS:
  576. //    dwComponentType - indicates the type of mixer component.
  577. //    lpszBuf         - points to buffer used to receive string.
  578. //    cbBuf           - size of buffer used to receive string.
  579. //
  580. //  RETURN VALUE:
  581. //    nothing.
  582. //    
  583. //  COMMENTS:
  584. //    
  585. //
  586.  
  587. void GetComponentTypeString(
  588.     DWORD dwComponentType,
  589.     LPSTR lpszBuf,
  590.     int cbBuf)
  591. {
  592.     int i;
  593.  
  594.     for (i = 0; i < MIXERCOMPONENT_TYPES; i++)
  595.         if (dwComponentType == adwComponentType[i][0])
  596.         {
  597.             LoadString(hInst, adwComponentType[i][1], lpszBuf, cbBuf);
  598.             return;
  599.         }
  600.  
  601.     // if dwComponentType was not found in the array, buffer is returned empty
  602. }
  603.  
  604.  
  605. //
  606. //  FUNCTION: GetControlTypeString(DWORD, LPSTR, int)
  607. //
  608. //  PURPOSE: Get the string describing the given type of mixer control.
  609. //
  610. //  PARAMETERS:
  611. //    dwControlType  - indicates the type of mixer control.
  612. //    lpszBuf        - points to buffer used to receive string.
  613. //    cbBuf          - size of buffer used to receive string.
  614. //
  615. //  RETURN VALUE:
  616. //    nothing.
  617. //    
  618. //  COMMENTS:
  619. //    
  620. //
  621.  
  622. void GetControlTypeString(
  623.     DWORD dwControlType,
  624.     LPSTR lpszBuf,
  625.     int cbBuf)
  626. {
  627.     int i;
  628.  
  629.     for (i = 0; i < MIXERCONTROL_TYPES; i++)
  630.         if (dwControlType == adwControlType[i][0])
  631.         {
  632.             LoadString(hInst, adwControlType[i][1], lpszBuf, cbBuf);
  633.             return;
  634.         }
  635.  
  636.     // if dwControlType was not found in the array, buffer is returned empty
  637. }
  638.